<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>电影详情</title>
    <%- include common %>
</head>
<body>
    <%- include('head', {title: 'movie', username: username}) %>

    <div class="container-fluid">
        <div class="container">
            <div class="row">
                <div class="col-md-6  col-sm-12">
                    <h4 class="text-primary text-center">电影介绍</h4>
                    <div class="thumbnail" style="cursor: pointer;">
                        <img style="height:240px;width:100%;" src="<%- result.images.large.replace(/img7/,'img3') %>"  alt="">
                        <div>
                            <p class="text-primary"><%- result.title %></p>
                            <p class="text-info">年份: <%- result.year %></p>
                            <p class="text-danger">评分: <%- result.rating.average %></p>
                            <p class="text-warning">分类: <%- result.genres %></p>
                            <p class="text-primary">导演: <%- result.directors[0].name %></p>

                            <p class="text-danger">演员:    
                            <% result.casts.forEach(v=>{ %>
                                    <span><%- v.name %> </span>
                            <% }) %>
                            </p>

                            <div style="width:100%;overflow: hidden;">
                                <div style="overflow: auto;">
                                    <% result.casts.forEach(v => { %>
                                            <img style="width:160px;height:200px;" src="<%- v.avatars.small.replace(/img7/,'img3') %>" />
                                    <% }) %>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-6  col-sm-12">
                    <h4 class="text-warning text-center">添加评论</h4>
                    <form method="POST" action="/comment/submit?mid=<%- result.id %>"  >
                        <div class="form-group" id="usernamebox">
                            <label for="title">评论标题</label>
                            <input type="text" name="title" class="form-control" id="title" placeholder="请输入评论标题">
                        </div>
                        <div class="form-group" >
                            <label for="content">评论内容</label>
                            <textarea rows="15"  name="content"  class="form-control" id="content" placeholder="请输入评论内容"></textarea>
                        </div>
                        <button type="submit" class="btn btn-warning">提交评论</button>
                        <button type="reset" class="btn btn-danger">重置</button>
                    </form>

                </div>
            </div>
        </div>
    </div>

    <%- include foot %>

    <script>
        // $("#content").xheditor(); // 简单的实例化 
        $(pageInit);
        function pageInit(){
            $.extend(XHEDITOR.settings,{shortcuts:{"ctrl+enter":submitForm}});
            // $("#ele").xheditor();
            $("#content").xheditor({   //初始化 富文件编辑框
                html5Upload:false,
                upMultiple:"1",

                upLinkRrl:"upload.html",
                upLinkExt:"zip,rar,txt",

                upImgUrl:"/comment/uploadImg",   // 图片上传的服务器  POST
                upImgExt:"jpg,jpeg,gif,png",

                upFlashUrl:"upload.php",
                upFlashExt:"swf",

                upMediaUrl:"upload.php",
                upMediaExt:"wmv,avi,wma,mp3,mid"

            });
        };

        function insertUpload(arrMsg){
            console.log(arrMsg);
            var i,msg;
            for(var i=0;i<arrMsg.length;i++){
                msg=arrMsg[i];
                console.log(msg);
                $("#uploadList").append('<option value="'+msg.id+'">'+msg.localname+'</option>')
            }
        };

        function submitForm(){
            $("#frmDemo").submit();
        }

    </script>
</body>
</html>